﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace EventScavenger
{
    internal class EventLogEntryEx
    {
        public int Index { get; set; }
        public string Message { get; set; }
        public DateTime TimeWritten { get; set; }
        public DateTime TimeGenerated { get; set; }
        public int InstanceId { get; set; }
        public string Source { get; set; }
        public string EntryType { get; set; }
        public string Category { get; set; }
        public string UserName { get; set; }
        public byte[] Data { get; set; }

        public static EventLogEntryEx FromEventLogEntry(EventLogEntry entry)
        {
            EventLogEntryEx newEventLogEntryEx = new EventLogEntryEx();
            newEventLogEntryEx.Index = entry.Index;            
            newEventLogEntryEx.TimeWritten = entry.TimeWritten;
            newEventLogEntryEx.TimeGenerated = entry.TimeGenerated;
            newEventLogEntryEx.InstanceId = (int)(entry.InstanceId & 65535);
            newEventLogEntryEx.EntryType = entry.EntryType.ToString();            
            newEventLogEntryEx.Source = entry.Source;            
            newEventLogEntryEx.Category = entry.Category;
            newEventLogEntryEx.UserName = newEventLogEntryEx.UserName;
            newEventLogEntryEx.Message = entry.Message;
            newEventLogEntryEx.Data = entry.Data;

            return newEventLogEntryEx;
        }
    }
}
